﻿@model RBS.Core.Model.U_User

@{
    ViewBag.Title = "食客认证";
    Layout = "~/Views/Shared/_UserLayout.cshtml";
    
    
    
}

<!--导航栏-->
@{
    @Html.Partial("_Location");
}
<!--/导航栏-->


@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true) 
    @Html.HiddenFor(model => model.Id);
    
    <div class="tab-content">
        <dl>
            <dt>认证手机</dt>
            <dd> 
                @if (Model.Status == 1)
                {
                   @Html.TextBoxFor(model => model.Mobile, new { @class = "input normal w120" })
                  <input type="button" id="btn" value="发送验证码" class="btn1 w100" /> 
                    <script type="text/javascript">
                        var wait = 60;

                        function time(o) {

                            if (wait == 0) {
                                o.removeAttribute("disabled");
                                o.value = "发送验证码";
                                wait = 60;

                            } else {
                                o.setAttribute("disabled", true);
                                o.value = "重新发送(" + wait + ")";
                                wait--;
                                setTimeout(function () {
                                    time(o);
                                },
                                    1000);
                            }
                        } 
                        document.getElementById("btn").onclick = function () {
                            $.ajax({
                                url: '@Url.Action("SendMsg")?mobile=' + $("#Mobile").val(),
                                type: 'Post',
                                dataType: 'json',
                                success: function (result) {
                                    if (result == null)
                                        return;

                                    alert(result.Msg);

                                }
                            });
                            time(this);
                        };
                    </script>
                }
                else
                {
                 @Html.DisplayFor(model => model.Mobile, new { @class = "input normal w120" })   <a id="EditMobile" href="javascript:;">修改手机</a> 
                   <div  id="UpdateMobile" style="display: none" class="tab-content"> 
                       <dl>
                           <dt>新手机</dt>
                           <dd>           
                                @Html.TextBoxFor(model => model.Mobile, new { @class = "input normal w120" })
                           </dd> 
                       </dl> 
                 </div> 
                  <script>
                      $(function () {
                          $("#EditMobile").click(function () {
                              $.dialog({
                                  id: 'Update', title: '修改认证手机', width: '150px', height: '50px', content: $("#UpdateMobile").html(), ok: function () {
                                      var msg = EditMobile($("#Id").val(), $("#Mobile").val());
                                      
                                      return false;
                                  }
                              });
                          });
                      }); 
                      function EditMobile(id,mobile) {
                          var url = '@Url.Action("EditMobile")';
                          $.ajax({
                              url: url,
                              type: "post",
                              dataType: 'json',
                              data: {
                                  id: id,
                                  mobile: mobile
                              },
                              success: function (result) {
                                  if (result.Success == true) {
                                      window.location.reload();
                                      return true;
                                  } else {
                                      $.dialog.alert(result.Msg);
                                      return false;
                                  } 
                              }
                          });
                      }
                  </script>   
                }
            </dd>
        </dl>
        @if (Model.Status == 1)
        {
            <dl>
                <dt>输入验证码</dt>

                <dd>
                    @Html.TextBox("yzm", null, new { @class = "input normal w120" })
                </dd>
            </dl>
             <!--工具栏-->
    <div class="page-footer">
        <div class="btn-list">
            <input type="submit" value="认证" class="btn" /> 
        </div>
        <div class="clear"></div>
    </div>
    <!--/工具栏-->
          
        }
    </div>
      

    <!--/内容-->


}


